﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _4_7
{
    public partial class Form1 : Form
    {
        private PictureBox pictureBoxRocket;
        private PictureBox pictureBoxBase;
        private Timer timer1;
        private ProgressBar progressBar1;
        private int rocketTop = 0;
        private int totalHeight = 0;

        public Form1()
        {
            InitializeComponent();
            this.DoubleClick += Form1_DoubleClick;

            // 初始化火箭图片框
            pictureBoxRocket = new PictureBox();
            pictureBoxRocket.Image = Image.FromFile("rocket.png"); // 替换为实际火箭图片路径
            pictureBoxRocket.SizeMode = PictureBoxSizeMode.AutoSize;
            pictureBoxRocket.Location = new Point((this.ClientSize.Width - pictureBoxRocket.Width) / 2, this.ClientSize.Height - pictureBoxRocket.Height);
            this.Controls.Add(pictureBoxRocket);
            rocketTop = pictureBoxRocket.Top;

            // 初始化发射基地图片框
            pictureBoxBase = new PictureBox();
            pictureBoxBase.Image = Image.FromFile("base.png"); // 替换为实际基地图片路径
            pictureBoxBase.SizeMode = PictureBoxSizeMode.AutoSize;
            pictureBoxBase.Location = new Point((this.ClientSize.Width - pictureBoxBase.Width) / 2, this.ClientSize.Height - pictureBoxBase.Height);
            this.Controls.Add(pictureBoxBase);

            // 初始化时钟控件
            timer1 = new Timer();
            timer1.Interval = 1;
            timer1.Tick += Timer1_Tick;

            // 初始化进度条
            progressBar1 = new ProgressBar();
            progressBar1.Dock = DockStyle.Top;
            progressBar1.Minimum = 0;
            totalHeight = this.ClientSize.Height - pictureBoxRocket.Height;
            progressBar1.Maximum = totalHeight;
            this.Controls.Add(progressBar1);
        }

        private void Form1_DoubleClick(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void Timer1_Tick(object sender, EventArgs e)
        {
            rocketTop--;
            pictureBoxRocket.Top = rocketTop;
            progressBar1.Value = totalHeight - rocketTop;

            if (rocketTop < 0 - pictureBoxRocket.Height)
            {
                timer1.Stop();
            }
        }
    }
}